package com.qpcy.controller;

import cn.hutool.core.lang.UUID;
import com.qpcy.config.MinioConfig;
import com.qpcy.utils.MinioUtils;
import com.qpcy.utils.OssUtils;
import com.qpcy.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;

/**
 * @author Cjl
 */
@RestController
@RequestMapping("/common")
public class CommonController {

    @Autowired
    private MinioUtils minioUtils;

    @Autowired
    private MinioConfig minioConfig;

    @Autowired
    private OssUtils ossUtils;

    /**
     * 上传
     *
     * @param files
     * @return
     */
    @PostMapping("/upload")
    public ResponseResult upload(@RequestParam List<MultipartFile> files) throws IOException {
        if (files.isEmpty()) {
            return ResponseResult.error("请上传文件");
        }
        return ResponseResult.success(ossUtils.upload(files));
    }


}
